package com.pk.springbootsy1.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.pk.springbootsy1.dto.TEquipmentDto;
import com.pk.springbootsy1.entity.TEquipment;
import com.pk.springbootsy1.mapper.TEquipmentMapper;
import com.pk.springbootsy1.service.TEquipmentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class TEquipmentServiceImpl extends ServiceImpl<TEquipmentMapper, TEquipment> implements TEquipmentService {
    @Autowired
    private TEquipmentMapper tEquipmentMapper;

    @Override
    public List<TEquipmentDto> getByUserId(Integer userId){
        LambdaQueryWrapper<TEquipment> lqw = new LambdaQueryWrapper<>();
        lqw.eq(TEquipment::getUserId,userId);
        return TEquipmentDto.convert(tEquipmentMapper.selectList(lqw)) ;
    }

    @Override
    public List<TEquipmentDto> listTEquipmentDto(){
        return TEquipmentDto.convert(tEquipmentMapper.selectList(null));
    }
}
